define(['zepto', 'butterfly/view','../../bsl',
    'text!./webview_animation.html'
], function($, View, bsl, webview_animation) {
    var me = null,ws,wo,wp;

    var view = View.extend({
        events: {

            // ！！！！ 由于 引入 touch.js 后，tap事件会变成双击，所以 本页面内不能使用tap，用click代替。
            "tap .openDoc" : "openDoc",
            "tap #back" : "back",
            "tap .ditem" : "setAnimation"

      
        },
        render: function() {
            me = this;
        },

        onShow: function() {

            // 绑定自定义事件 滑动切换日历等           
            this.bslReady();

        },

        // H5 bsl事件处理
          bslReady:function (){
            ws=bsl.webview.currentWebview();
            wo=ws.opener();
            wp=bsl.webview.create('webview_new.html','webview_new.html',{scrollIndicator:'none',scalable:false,popGesture:'none'},{preate:true});
        },
        // if(window.bsl){
        //     bslReady();
        // }else{
        //     document.addEventListener('bslready',bslReady,false);
        // }
        // 动画窗口
        animateWindow:function (type){
            wp.show(type);
        },
        // 关闭窗口
        preateBack:function (){
            if(!ws.preate){
                wp&&wp.close();
            }
        },

          back : function(e){
            this.preateBack();
            window.history.go(-1);
            
        },
        setAnimation: function(e){console.log(e);
            var type = $(e.currentTarget).attr('id');
            this.animateWindow(type);
        }
     
             
            });
    return view;
});
